package com.dooioo.fangyou.service;

import java.util.List;
import java.util.Map;

/**
 * 基本的业务层接口，支持多数据源
 * 默认数据源为queryDao，其他数据源需要set相应的数据源
 * <code>
 * public void setQueryTestDao(QueryDao queryTestDao) {
 *     this.queryDao = queryTestDao; 
 *}
 * </code>
 * User: kqy
 * Date: 2010-11-30
 * Time: 15:05:36
 */
public interface BaseService<T> {

    public final static String QUERY_GET = "get";
    public final static String QUERY_FIND = "find";
    public final static String QUERY_INSERT = "insert";
    public final static String QUERY_UPDATE = "update";
    public final static String QUERY_DELETE = "delete";
    /**
     * 通过主键查找，返回对应的model
     * 约定主键规则为：modelName + Id，例如：EstateId
     * @param id
     * @return
     */
    public abstract T findById(String id);

    public abstract T findById(String sqlId, String id);

    /**
     * 指定列名值查找，返回对应的model
     * @param column 列名
     * @param param 参数值
     * @return
     */
    public abstract T findBy(String column, String param);
    public abstract T findBy(String sqlId, String column, String param);

    public abstract List<T> queryForList();
    public abstract List<T> queryForList(String sqlId);

    public abstract int insert(T entityObject);
    public abstract int insert(String sqlId, T entityObject);
    public abstract int insert(String sqlId, Map<String, Object> bindParams);

    public abstract int update(T entityObject);
    public abstract int update(String sqlId, T entityObject);
    public abstract int update(String sqlId, Map<String, Object> bindParams);

    public abstract int delete(String id);
    public abstract int delete(String sqlId, T entityObject);
    public abstract int delete(String sqlId, Map<String, Object> bindParams);

}
